package com.yswy.app.dto;

import com.yswy.common.enums.DateUnitEnums;
import com.yswy.domain.entity.VipPrice;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;

@Data
@ApiModel("vip价格表")
public class VipPriceVo {
    private Long id;
    @ApiModelProperty("商品类型 0 金币购买  1 vip购买")
    private Integer goodType;
    @ApiModelProperty("价格(分)")
    private Integer price;
    @ApiModelProperty("是否可以使用支付宝支付")
    private Boolean isZfbPay;
    @ApiModelProperty("是否可以使用微信支付")
    private Boolean isWxPay;
    @ApiModelProperty("显示状态 0:不显示 1:显示")
    private Integer salesStatus;
    @ApiModelProperty("是否是新手套餐 ")
    private Boolean isDisposable;

    @ApiModelProperty("说明")
    private String descDetails;
    @ApiModelProperty("标签")
    private String tags;
    @ApiModelProperty("价格字符串")
    private String priceString;
    @ApiModelProperty("原价")
    private String originalPrice;
    @ApiModelProperty("发放金币数字符串")
    private String moneyCodeString;
    @ApiModelProperty("赠送说明字符串")
    private String giveString;
    @ApiModelProperty("背景图Url")
    private String bgImg;
    @ApiModelProperty("商品名字")
    private String vipName;


    //周期扣款配置
    @ApiModelProperty("是否是周期付款产品")
    private Boolean isWithdrawal;
    @ApiModelProperty("续费说明")
    private String illustrate ;


    public VipPriceVo(VipPrice vipPrice ) {
        this.id = vipPrice.getId();
        this.goodType= vipPrice.getGoodType();
        this.price= vipPrice.getPrice();
        this.isZfbPay= vipPrice.getIsZfbPay();
        this.isWxPay= vipPrice.getIsWxPay();
        this.salesStatus= vipPrice.getSalesStatus();
        this.isDisposable= vipPrice.getIsDisposable();
        this.descDetails= vipPrice.getDescDetails();
        this.tags= vipPrice.getTags();
        this.priceString= vipPrice.getPriceString();
        this.originalPrice= vipPrice.getOriginalPrice();
        this.moneyCodeString= vipPrice.getMoneyCodeString();
        this.giveString= vipPrice.getGiveString();
        this.bgImg= vipPrice.getBgImg();
        this.vipName= vipPrice.getVipName();
        this.isWithdrawal= vipPrice.getIsWithdrawal();
        this.illustrate= vipPrice.getIllustrate() ;

    }




    public static String getPriceString(Double price){
        BigDecimal value = new BigDecimal(price).setScale(2, RoundingMode.HALF_UP);
        BigDecimal noZeros = value.stripTrailingZeros();
        String result = noZeros.toPlainString();
        return result ;

    }

    public static void main(String[] args) {
        Integer v = 910 ;
        System.out.println(v.doubleValue()/100);
        System.out.println(getPriceString(v.doubleValue()/100));
    }

}
